<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
--><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>Cordova API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
</head>
<body>
        <div id="header">
            <h1><a href="index.html"><strong>Cordova</strong> Documentation</a></h1>
            <small>
                <select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="1.7.0rc1">1.7.0rc1</option>
<option selected value="1.7.0">1.7.0</option>
<option value="1.6.1">1.6.1</option>
<option value="1.6.0rc1">1.6.0rc1</option>
<option value="1.6.0">1.6.0</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value="0.9.5.1">0.9.5.1</option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
</optgroup>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
</optgroup>
<optgroup label="Japanese" value="jp"><option value="0.9.5">0.9.5</option></optgroup></select></small>
        </div>
        <div id="subheader">
            <h1>Notification</h1>
            <small><select><option value="Notification">Notification</option>
<option value="Notification_methods">      - Methods</option>
<option value="notification.alert">notification.alert</option>
<option value="notification.alert_description">      - Description</option>
<option value="notification.alert_supported_platforms">      - Supported Platforms</option>
<option value="notification.alert_quick_example">      - Quick Example</option>
<option value="notification.alert_full_example">      - Full Example</option>
<option value="notification.alert_windows_phone_7_quirks">      - Windows Phone 7 Quirks</option>
<option value="notification.alert_bada_2_x_quirks">      - Bada 2.x Quirks</option>
<option value="notification.confirm">notification.confirm</option>
<option value="notification.confirm_description">      - Description</option>
<option value="notification.confirm_supported_platforms">      - Supported Platforms</option>
<option value="notification.confirm_quick_example">      - Quick Example</option>
<option value="notification.confirm_full_example">      - Full Example</option>
<option value="notification.confirm_windows_phone_7_quirks">      - Windows Phone 7 Quirks</option>
<option value="notification.confirm_bada_2_x_quirks">      - Bada 2.x Quirks</option>
<option value="notification.confirm_bada_1_2_quirks">      - Bada 1.2 Quirks</option>
<option value="notification.beep">notification.beep</option>
<option value="notification.beep_supported_platforms">      - Supported Platforms</option>
<option value="notification.beep_quick_example">      - Quick Example</option>
<option value="notification.beep_full_example">      - Full Example</option>
<option value="notification.beep_android_quirks">      - Android Quirks</option>
<option value="notification.beep_iphone_quirks">      - iPhone Quirks</option>
<option value="notification.beep_windows_phone_7_quirks">      - Windows Phone 7 Quirks</option>
<option value="notification.vibrate">notification.vibrate</option>
<option value="notification.vibrate_supported_platforms">      - Supported Platforms</option>
<option value="notification.vibrate_quick_example">      - Quick Example</option>
<option value="notification.vibrate_full_example">      - Full Example</option>
<option value="notification.vibrate_iphone_quirks">      - iPhone Quirks</option></select></small>
        </div>

        <div id="sidebar">
            <div class="vertical_divider"></div>
        <h1>API Reference</h1>
<ul>
<li><a href="cordova_accelerometer_accelerometer.md.html#Accelerometer">Accelerometer</a></li>
<li><a href="cordova_camera_camera.md.html#Camera">Camera</a></li>
<li><a href="cordova_media_capture_capture.md.html#Capture">Capture</a></li>
<li><a href="cordova_compass_compass.md.html#Compass">Compass</a></li>
<li><a href="cordova_connection_connection.md.html#Connection">Connection</a></li>
<li><a href="cordova_contacts_contacts.md.html#Contacts">Contacts</a></li>
<li><a href="cordova_device_device.md.html#Device">Device</a></li>
<li><a href="cordova_events_events.md.html#Events">Events</a></li>
<li><a href="cordova_file_file.md.html#File">File</a></li>
<li><a href="cordova_geolocation_geolocation.md.html#Geolocation">Geolocation</a></li>
<li><a href="cordova_media_media.md.html#Media">Media</a></li>
<li><a href="cordova_notification_notification.md.html#Notification">Notification</a></li>
<li><a href="cordova_storage_storage.md.html#Storage">Storage</a></li>
</ul>
<h1>Guides</h1>
<ul>
<li><a href="guide_getting-started_index.md.html#Getting%20Started%20Guides">Getting Started Guides</a></li>
<li><a href="_index.html">Keyword Index</a></li>
</ul>
</div>

        <div id="scrollable">
            <div id="content">
                <h1><a name="Notification">Notification</a></h1>

<blockquote>
  <p>Visual, audible, and tactile device notifications.</p>
</blockquote>

<h2>
<a name="Notification_methods">Methods</a>
</h2>

<ul>
<li><a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a></li>
<li><a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a></li>
<li><a href="cordova_notification_notification.md.html#notification.beep">notification.beep</a></li>
<li><a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a></li>
</ul>
<hr>
<h1><a name="notification.alert">notification.alert</a></h1>

<p>Shows a custom alert or dialog box.</p>

<pre class="prettyprint"><code>navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>(message, alertCallback, [title], [buttonName])
</code></pre>

<ul>
<li>
<strong>message:</strong> Dialog message (<code>String</code>)</li>
<li>
<strong>alertCallback:</strong> Callback to invoke when alert dialog is dismissed. (<code>Function</code>)</li>
<li>
<strong>title:</strong> Dialog title (<code>String</code>) (Optional, Default: "Alert")</li>
<li>
<strong>buttonName:</strong> Button name (<code>String</code>) (Optional, Default: "OK")</li>
</ul>
<h2>
<a name="notification.alert_description">Description</a>
</h2>

<p>Most Cordova implementations use a native dialog box for this feature.  However, some platforms simply use the browser's <code>alert</code> function, which is typically less customizable.</p>

<h2>
<a name="notification.alert_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
<li>Bada 1.2 &amp; 2.x</li>
</ul>
<h2>
<a name="notification.alert_quick_example">Quick Example</a>
</h2>

<pre class="prettyprint"><code>// Android / BlackBerry WebWorks (OS 5.0 and higher) / iPhone
//
function alertDismissed() {
    // do something
}

navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>(
    'You are the winner!',  // message
    alertDismissed,         // callback
    'Game Over',            // title
    'Done'                  // buttonName
);
</code></pre>

<h2>
<a name="notification.alert_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_notification_notification.md.html#Notification">Notification</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // alert dialog dismissed
    function alertDismissed() {
        // do something
    }

    // Show a custom alert
    //
    function showAlert() {
        navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>(
            'You are the winner!',  // message
            alertDismissed,         // callback
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;&lt;a href="#" onclick="showAlert(); return false;"&gt;Show Alert&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>
<a name="notification.alert_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>

<ul>
<li>Ignores button names, always uses 'OK'</li>
<li>There is no built in browser alert, so if you want to just write alert('foo'); you can assign window.alert = navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>;</li>
<li>alert + confirm calls are non-blocking, and result is only available asyncronously.</li>
</ul>
<h2>
<a name="notification.alert_bada_2_x_quirks">Bada 2.x Quirks</a>
</h2>

<ul>
<li>alert uses javascript alert</li>
</ul>
<hr>
<h1><a name="notification.confirm">notification.confirm</a></h1>

<p>Shows a customizable confirmation dialog box.</p>

<pre class="prettyprint"><code>navigator.<a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a>(message, confirmCallback, [title], [buttonLabels])
</code></pre>

<ul>
<li>
<strong>message:</strong> Dialog message (<code>String</code>)</li>
<li>
<strong>confirmCallback:</strong> - Callback to invoke with index of button pressed (1, 2 or 3). (<code>Number</code>)</li>
<li>
<strong>title:</strong> Dialog title (<code>String</code>) (Optional, Default: "Confirm")</li>
<li>
<strong>buttonLabels:</strong> Comma separated string with button labels (<code>String</code>) (Optional, Default: "OK,Cancel")</li>
</ul>
<h2>
<a name="notification.confirm_description">Description</a>
</h2>

<p>Function <code><a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a></code> displays a native dialog box that is more customizable than the browser's <code>confirm</code> function.</p>

<h2>
<a name="notification.confirm_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
<li>Bada 1.2 &amp; 2.x</li>
</ul>
<h2>
<a name="notification.confirm_quick_example">Quick Example</a>
</h2>

<pre class="prettyprint"><code>// process the confirmation dialog result
function onConfirm(button) {
    alert('You selected button ' + button);
}

// Show a custom confirmation dialog
//
function showConfirm() {
    navigator.<a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a>(
        'You are the winner!',  // message
        onConfirm,              // callback to invoke with index of button pressed
        'Game Over',            // title
        'Restart,Exit'          // buttonLabels
    );
}
</code></pre>

<h2>
<a name="notification.confirm_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_notification_notification.md.html#Notification">Notification</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // process the confirmation dialog result
    function onConfirm(button) {
        alert('You selected button ' + button);
    }

    // Show a custom confirmation dialog
    //
    function showConfirm() {
        navigator.<a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a>(
            'You are the winner!',  // message
            onConfirm,              // callback to invoke with index of button pressed
            'Game Over',            // title
            'Restart,Exit'          // buttonLabels
        );
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;&lt;a href="#" onclick="showConfirm(); return false;"&gt;Show Confirm&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>
<a name="notification.confirm_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>

<ul>
<li>Ignores button names, always 'OK|Cancel'</li>
<li>There is no built in browser confirm, so if you want to just write alert('foo'); you can assign window.confirm = navigator.<a href="cordova_notification_notification.md.html#notification.confirm">notification.confirm</a>;</li>
<li>alert + confirm calls are non-blocking, and result is only available asyncronously.</li>
</ul>
<h2>
<a name="notification.confirm_bada_2_x_quirks">Bada 2.x Quirks</a>
</h2>

<ul>
<li>confirm uses javascript alert</li>
</ul>
<h2>
<a name="notification.confirm_bada_1_2_quirks">Bada 1.2 Quirks</a>
</h2>

<ul>
<li>Ignore button names, always 'OK|Cancel'</li>
</ul>
<hr>
<h1><a name="notification.beep">notification.beep</a></h1>

<p>The device will play a beep sound.</p>

<pre class="prettyprint"><code>navigator.<a href="cordova_notification_notification.md.html#notification.beep">notification.beep</a>(times);
</code></pre>

<ul>
<li>
<strong>times:</strong> The number of times to repeat the beep (<code>Number</code>)</li>
</ul>
<h2>
<a name="notification.beep_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
<li>Bada 1.2 &amp; 2.x</li>
</ul>
<h2>
<a name="notification.beep_quick_example">Quick Example</a>
</h2>

<pre class="prettyprint"><code>// Beep twice!
navigator.<a href="cordova_notification_notification.md.html#notification.beep">notification.beep</a>(2);
</code></pre>

<h2>
<a name="notification.beep_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_notification_notification.md.html#Notification">Notification</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // Show a custom alert
    //
    function showAlert() {
        navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>(
            'You are the winner!',  // message
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    // Beep three times
    //
    function playBeep() {
        navigator.<a href="cordova_notification_notification.md.html#notification.beep">notification.beep</a>(3);
    }

    // Vibrate for 2 seconds
    //
    function vibrate() {
        navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2000);
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;&lt;a href="#" onclick="showAlert(); return false;"&gt;Show Alert&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="#" onclick="playBeep(); return false;"&gt;Play Beep&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="#" onclick="vibrate(); return false;"&gt;Vibrate&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>
<a name="notification.beep_android_quirks">Android Quirks</a>
</h2>

<ul>
<li>Android plays the default "<a href="cordova_notification_notification.md.html#Notification">Notification</a> ringtone" specified under the "Settings/Sound &amp; Display" panel.</li>
</ul>
<h2>
<a name="notification.beep_iphone_quirks">iPhone Quirks</a>
</h2>

<ul>
<li>Ignores the beep count argument.</li>
<li>There is no native beep API for iPhone.
<ul>
<li>Cordova implements beep by playing an audio file via the media API.</li>
<li>The user must provide a file with the desired beep tone.</li>
<li>This file must be less than 30 seconds long, located in the www/ root, and must be named <code>beep.wav</code>.</li>
</ul>
</li>
</ul>
<h2>
<a name="notification.beep_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>

<ul>
<li>WP7 Cordova lib includes a generic beep file that is used.</li>
</ul>
<hr>
<h1><a name="notification.vibrate">notification.vibrate</a></h1>

<p>Vibrates the device for the specified amount of time.</p>

<pre class="prettyprint"><code>navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(milliseconds)
</code></pre>

<ul>
<li>
<strong>time:</strong> Milliseconds to vibrate the device. 1000 milliseconds equals 1 second (<code>Number</code>)</li>
</ul>
<h2>
<a name="notification.vibrate_supported_platforms">Supported Platforms</a>
</h2>

<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7</li>
<li>Bada 1.2 &amp; 2.x</li>
</ul>
<h2>
<a name="notification.vibrate_quick_example">Quick Example</a>
</h2>

<pre class="prettyprint"><code>// Vibrate for 2.5 seconds
//
navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2500);
</code></pre>

<h2>
<a name="notification.vibrate_full_example">Full Example</a>
</h2>

<pre class="prettyprint"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;<a href="cordova_notification_notification.md.html#Notification">Notification</a> Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for Cordova to load
    //
    document.addEventListener("<a href="cordova_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // Show a custom alert
    //
    function showAlert() {
        navigator.<a href="cordova_notification_notification.md.html#notification.alert">notification.alert</a>(
            'You are the winner!',  // message
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    // Beep three times
    //
    function playBeep() {
        navigator.<a href="cordova_notification_notification.md.html#notification.beep">notification.beep</a>(3);
    }

    // Vibrate for 2 seconds
    //
    function vibrate() {
        navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2000);
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;&lt;a href="#" onclick="showAlert(); return false;"&gt;Show Alert&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="#" onclick="playBeep(); return false;"&gt;Play Beep&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="#" onclick="vibrate(); return false;"&gt;Vibrate&lt;/a&gt;&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<h2>
<a name="notification.vibrate_iphone_quirks">iPhone Quirks</a>
</h2>

<ul>
<li>
<p><strong>time:</strong> Ignores the time and vibrates for a pre-set amount of time.</p>

<pre class="prettyprint"><code>navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>();
navigator.<a href="cordova_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2500);   // 2500 is ignored
</code></pre>
</li>
</ul>
</div>
        </div>

        <!-- Functionality and Syntax Highlighting -->
        <script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
</body>
</html>
